<!--
 * @Descripttion: 
 * @version: 
 * @Author: zhangzhanhua
 * @Date: 2020-10-31 10:00:22
 * @LastEditors: gonghairun
 * @LastEditTime: 2022-07-19 12:52:06
-->

<!-- 帆软BI及报表展示 -->
<template>
	<div class="link-home">
		<div id="iframe-container">
			<iframe
				v-for="(item, index) in fineLinks"
				v-show="item.isShow"
				:key="index"
				:src="item.link"
				scrolling="auto"
				frameborder="0"
				id="iframe"
			></iframe>
		</div>
	</div>
</template>

<script>
//import NProgress from 'nprogress'

export default {
	data() {
		return {
			title: "",
			link: "",
			fineLinks: [],
		}
	},
	mounted() {
		// let iframe = document.getElementById('iframe')
		// alert(this.$route.meta.title)
		this.title = this.$route.meta.title
		this.link = this.$route.meta.link
		this.initData()
	},
	watch: {
		$route: function (to) {
			console.log(to)
			this.title = this.$route.meta.title
			this.link = this.$route.meta.link
			if (this.link) {
				this.initData()
			}
		},
	},
	methods: {
		initData() {
			var fineLinks = localStorage.getItem("fineLinks")
			fineLinks = fineLinks ? JSON.parse(fineLinks) : []
			//存入缓存中
			var jsonObj = { title: this.title, link: this.link, isShow: true }
			fineLinks.map(item => {
				if (item.title === this.title) {
					item.isShow = true
				} else {
					item.isShow = false
				}
			})
			var filterA = fineLinks.filter(item => item.title == this.title)
			if (filterA.length == 0) {
				fineLinks.push(jsonObj)
			}
			fineLinks.map(item => {
				if (item.title == "金港主要指标完成情况") {
					item.link = item.link + "&op=write"
				}
			})
			this.fineLinks = fineLinks
			console.log(fineLinks, "fineLinks")
			localStorage.setItem("fineLinks", JSON.stringify(fineLinks))
		},
	},
}
</script>
<style lang="less" scoped>
.link-home {
	width: 100%;
	height: 100%;
}
#iframe-container {
	width: 100%;
	height: 100%;
}
#iframe {
	width: 100%;
	height: 100%;
}
</style>
